{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Url::build($Request.action)}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>分类名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" name="name" datatype="*" nullmsg="请填写分类名称">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>选择父分类：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <select class="select-box" name="pid">
                    <option value="">-- 选择父分类 --</option>
                    <option value="0">顶级分类</option>
                    {volist name="topcates" id="vo"}
                        <option value="{$vo.cate_id}">{$vo.name}</option>
                    {/volist}
                </select>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>图片：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" name="pic" id="upload-1" placeholder="请点击后面的上传按钮" style="width: 70%">
                <button type="button" class="btn btn-primary radius" onclick="layer_open('文件上传','{:\\think\\Url::build(\'Upload/index\', [\'id\' => \'upload-1\'])}')">上传</button>
                <!--<a onclick="$(this).attr('href', '__ROOT__/'+$('#upload').val())" type="button" class="btn btn-success radius" data-lightbox="preview">预览</a>-->
            </div>
            <div class="col-xs-3 col-sm-3">
                <img src="" height="80" width="100" id="preimg-upload-1"  alt="预览图片">
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>

<script>
    $(function () {
        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                ajax_progress(ret,function () {
                    $("#encode").html(ret.data.encode);
                    $("#decode").html(ret.data.decode);
                });
                // 提交成功
                if(ret.code==0){
                    parent.location.reload();
                } else {
                    layer.alert(ret.msg);
                    return false;
                }

            }
        });

    })
</script>
{/block}